package xuesm.proxy.dynamic.facemeng;

import java.lang.reflect.Method;

/**
 * @Author: xuesm
 * @Description: 手写jdk动态代理，代理类
 * @Date: Create in 12:31 2019/4/3
 */
public class FMAgent implements FMInvocationHandler{


	private Object obj;
	public Object getInstance(Object object){
		this.obj = object;
		Class<?> clazz = object.getClass();
		return FMProxy.newProxyInstance(new FMClassLoader(), clazz.getInterfaces(), this);
	}



	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

		before();
		Object object = method.invoke(this.obj, args);
		after();
		
		
		return null;
	}

	private void after() {
		System.out.println("安排明星（体育， 演员）衣食住行");
	}

	private void before() {
		System.out.println("（给运动员）联系俱乐部，或者（给演员）联系公司接剧本");
	}
}
